RDBC-1037 RDBC-1038 Fix load_into_stream and implement stream_into/to_stream#278
RDBC-1037 RDBC-1038 Fix load_into_stream and implement stream_into/to_stream#278redknightlois wants to merge 1 commit intoravendb:v7.2from
Conversation
4dee4e0 to
a6503a6
Compare
|
please bump PR to run checks |
| return load_operation.get_documents(object_type) | ||
|
|
||
| def _load_internal_stream(self, keys: List[str], operation: LoadOperation, stream: Optional[bytes] = None) -> None: | ||
| def _load_internal_stream(self, keys: List[str], operation: LoadOperation, stream=None) -> None: |
There was a problem hiding this comment.
please provide typehint for stream parameter
should be fixed type, Union, or Protocol
There was a problem hiding this comment.
write a docstring on the use-case of this method - when to use, should provide file stream/BytesIO?
There was a problem hiding this comment.
What if we use BinaryIO which is the parallel to Stream in C#?
There was a problem hiding this comment.
The other usage is attachments stream which is a readable stream (or raw bytes). StoreAttachmentParameters.__init__ is untyped and PutAttachmentOperation.__init__ typed bytes. We would need to think in the public API what impact it has if we want to standarize.
bb0c73f to
7176e83
Compare
|
|
||
| def stream_into(self): # query: Union[DocumentQuery, RawDocumentQuery], output: iter): | ||
| pass | ||
| def stream_into(self, query: AbstractDocumentQuery, output: BinaryIO) -> None: |
There was a problem hiding this comment.
let's add docstring here
| @@ -404,16 +407,19 @@ def load_starting_with( | |||
| def load_starting_with_into_stream( | |||
There was a problem hiding this comment.
let's add docstring here
| self._suggest_using(suggestion_or_builder) | ||
| return SuggestionDocumentQuery(self) | ||
|
|
||
| def to_stream(self, output: BinaryIO) -> None: |
There was a problem hiding this comment.
let's add docstring here
| self._projection(projection_behavior) | ||
| return self | ||
|
|
||
| def to_stream(self, output: BinaryIO) -> None: |
There was a problem hiding this comment.
let's add docstring here
…ssion streaming APIs
- _load_internal_stream: write serialized result to output stream instead of reading from it; broaden exception handler from IOError to Exception and use proper raise-from chaining; filter None fields from to_json() output so the stream matches the server wire format (only fields the server actually sent)
- load_starting_with_into_stream: add required output parameter, validate it, fix grammar error in id_prefix guard message, delegate to internal helper; filter None fields at write site
- stream_into: implemented; writes {"Results":[...]} incrementally to output as JSONL items arrive — no full in-memory buffering; matches C# StreamInto format expected by JObject.Load / json.GetValue("Results") tests
- DocumentQuery.to_stream / RawDocumentQuery.to_stream: convenience wrappers over session.advanced.stream_into
Tests:
- dotnet migrated test (RDBC-1037): load_into_stream and load_starting_with_into_stream write valid JSON to BytesIO; every integration test asserts exact count and field values
- dotnet migrated test (RDBC-1038): stream_into and to_stream write Results JSON; each integration test asserts count and field values for every result; unit test verifies the method rejects non-query arguments at runtime
- JVM migrated test: adds test_can_load_by_ids_into_stream (port of C# CanLoadByIdsIntoStream) alongside the existing load_starting_with test
7176e83 to
a5dcb6c
Compare
Issue link
https://issues.hibernatingrhinos.com/issue/RDBC-1037
https://issues.hibernatingrhinos.com/issue/RDBC-1038
Additional description
RDBC-1037 –
session.advanced.load_into_stream()andload_starting_with_into_stream()were broken: the implementation was reading from the output stream instead of writing to it, so callers always received an empty result. Fixed to serialize documents and write them to the provided stream.RDBC-1038 – Adds
session.advanced.stream_into(query, output), which streams query results incrementally to an output stream without buffering the full result set in memory. Also addsDocumentQuery.to_stream()andRawDocumentQuery.to_stream()as convenience wrappers. The output format matches the C#StreamIntowire format ({"Results":[...]}).Type of change
How risky is the change?
Backward compatibility
Is it platform specific issue?
Documentation update
Documentation Requiredtag.Testing by Contributor
private)Testing by RavenDB QA team
QA Requiredtag.Is there any existing behavior change of other features due to this change?
UI work
Studio Requiredtag.